#define _CRT_SECURE_NO_WARNINGS 1


#include<list>
#include<vector>
#include<iostream>

using namespace std;


 struct ListNode 
{
    int val;
    struct ListNode *next;
    ListNode(int x) : val(x), next(nullptr) {}
};

ListNode* mergeKLists(vector<ListNode*>& lists)
{
    list<int> lt;
    for (int i = 0; i < lists.size(); i++)
    {
        ListNode* cur = lists[i];
        while (cur)
        {
            lt.push_back(cur->val);
            cur = cur->next;
        }
    }
    lt.reverse();
    ListNode* ret = new ListNode(lt.front());
    ListNode* head = ret;
    auto it = lt.begin();
    it++;
    while (it != lt.end())
    {
        ListNode* node = new ListNode(*it);
        ret->next = node;
        ret = ret->next;
    }
    return head;
}

int main()
{


    return 0;
}